package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.bean.GbServerBean;
import com.topnav.mc.admin.entity.param.GbServerParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import com.topnav.mc.admin.entity.GbServer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GbServerMapper extends McMapper<GbServer, GbServerBean, GbServerParam> {
    String commSql = " SELECT s.*, c.position AS cityName, b.name AS businessName, ct.name AS centerTypeName," +
            " dt.name AS deviceTypeName, n.name netIdentity " +
            " FROM mc_gb_server s " +
            " LEFT JOIN mc_code_city c ON s.city_id = c.id " +
            " LEFT JOIN mc_code_business b ON s.business_id = b.id " +
            " LEFT JOIN mc_code_type ct ON s.center_type_id = ct.id " +  //服务器类型
            " LEFT JOIN mc_code_type dt ON s.device_type_id = dt.id " +  //设备类型
            " LEFT JOIN mc_code_net_identity n ON s.net_identity_id = n.id  " +
            " ${ew.customSqlSegment}";

    @Select(commSql)
    GbServerBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<GbServerBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<GbServerBean> selectInfoPage(Page<GbServerParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);


}
